import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2023-11-22
 * Time: 20:33
 */
public class Main {

    public static User login() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的姓名:");
        String name = scanner.nextLine();
        System.out.println("请输入你的身份: 1代表管理员 0代表普通用户");
        int choice = scanner.nextInt();
        if(choice == 1) {
            return new AdminUser(name);
        }else {
            return new NormalUser(name);
        }
    }


    public static void main(String[] args) {
        // 书架上一开始就要有书
        BookList bookList = new BookList();
        // user会指向哪个用户,是由login()的返回值决定的
        User user = login();
       while (true) {
           // 登录之后要打印菜单,根据返回的值来确认操作
           int choice = user.menu();
           // 在user父类中, 将choice与所做的操作结合在了一起
           user.doOperation(choice,bookList);
       }
    }

}
